#!/usr/bin/env python
# -*- coding: utf-8 -*-

# 
# 
# 
# 
import psutil

print psutil.disk_partitions()
#[
# sdiskpart(device='/dev/xvda1', mountpoint='/', fstype='ext4', opts='rw,relatime,data=ordered'), 
# sdiskpart(device='/dev/xvdb1', mountpoint='/data', fstype='ext3', opts='rw,relatime,data=ordered'), 
# sdiskpart(device='/dev/xvda1', mountpoint='/var/lib/docker/overlay', fstype='ext4', opts='rw,relatime,data=ordered')]

print psutil.disk_io_counters()
# sdiskio(
# read_count=1202381, 
# write_count=6379890, 
# read_bytes=47496886272, 
# write_bytes=115575382016, 
# read_time=6267334, 
# write_time=422002183, 
# read_merged_count=6580, 
# write_merged_count=10720395, 
# busy_time=11437600)
print psutil.disk_usage('/')
# sdiskusage(total=42140499968, 
#used=6085890048, 
#free=33890402304, 
#percent=15.2)


# 通过每1秒的采样，可以获取到 read/write time，然后计算 util%
print psutil.disk_io_counters(perdisk=True)
# {
#'xvdb1': sdiskio(read_count=1157536, 
# write_count=1075619, 
# read_bytes=46700557312, 
# write_bytes=47110397952, 
# read_time=5891015, 
# write_time=217253623, 
# read_merged_count=6353, 
# write_merged_count=8412581, 
# busy_time=2599506), 
# 
#'xvda1': sdiskio(read_count=44845, 
# write_count=5304271, 
# read_bytes=796328960, 
# write_bytes=68464984064, 
# read_time=376319, 
# write_time=204748560, 
# read_merged_count=227, 
# write_merged_count=2307814, 
# busy_time=8838094)}